<html>

<head>

<title>EQ Emu - Account List</title>

<?php

$time_start = microtime(true);
include "../includes/constants.php";
include "../includes/functions.php";

if (!isset($_GET["limit"])) $_GET["limit"] = 10;
if ((!isset($_GET["offset"]) || ($_GET["offset"] == ""))) $_GET["offset"] = 0;

?>

</head>

<body>

<center><h1>Account List</h1></center>

<table align="center" border="1">
	<form method="GET" action="">
	<caption align="top" style="text-align:right">
		<?php CreateResultLimit();?>
	</caption>
	<tr>
		<th><?php SortLink(id,'ID');?></th>
		<th><?php SortLink(name,'Acct Name');?></th>
		<th><?php SortLink(charname,'Last Char');?></th>
		<th><?php SortLink(sharedplat,'Shared Plat',DESC);?></th>
		<th><?php SortLink(password,'P/W',DESC);?></th>
		<th><?php SortLink(status,'Status',DESC);?></th>
		<th><?php SortLink(lsaccount_id,'LS Acct ID');?></th>
		<th><?php SortLink(gmspeed,'GM Speed',DESC);?></th>
		<th><?php SortLink(revoked,'Revoked');?></th>
<!--		<th><?php // SortLink(minilogin_ip,'Minilogin IP');?></th>	-->
		<th><?php SortLink(hideme,'Hide Me',DESC);?></th>
		<th><?php SortLink(rulesflag,'Rules Flag',DESC);?></th>
	</tr>
<?php flush(); ob_flush();?>	<tr>
		<td>
			<?php // CreateDropdown(id,account);?>&nbsp;
		</td>
		<td>
			<?php // CreateDropdown(name,account);?>&nbsp;
		</td>
		<td>
			<?php // CreateDropdown(charname,account);?>&nbsp;
		</td>
		<td>
			<?php // CreateDropdown(sharedplat,account);?>&nbsp;
		</td>
		<td>
			<?php // CreateDropdown(password,account);?>&nbsp;
		</td>
		<td>
			<?php CreateDropdown(status,account,DESC);?>&nbsp;
		</td>
		<td>
			<?php // CreateDropdown(lsaccount_id,account);?>&nbsp;
		</td>
		<td>
			<?php CreateDropdown(gmspeed,account,DESC);?>&nbsp;
		</td>
		<td>
			<?php CreateDropdown(revoked,account,DESC);?>&nbsp;
		</td>
<!--		<td>
			<?php // CreateDropdown(minilogin_ip,account);?>&nbsp;
		</td>
-->		<td>
			<?php CreateDropdown(hideme,account,DESC);?>&nbsp;
		</td>
		<td>
			<?php CreateDropdown(rulesflag,account,DESC);?>&nbsp;
		</td>
	</tr>
	</form>
<?php

flush(); ob_flush();
mysql_select_db("peq");
if (!isset($_GET["sort"]) || ($_GET["sort"] == "")) $_GET["sort"] = "id";
if (!isset($_GET["dir"]) || ($_GET["dir"] == "")) $_GET["dir"] = "DESC";
$query = "SELECT account.*, character_.id AS character_id FROM account LEFT JOIN character_ ON account.charname=character_.name ";
if ($_GET["id"]) {$query .= " WHERE account.id=" . $_GET["id"] . " ";} 
else {$query .= " ORDER BY " . $_GET["sort"] . " " . $_GET["dir"] . " ";};
// Limit query if $_GET["limit"] is set
if ($_GET["limit"] != "") $query .= " LIMIT " . $_GET["limit"] . " OFFSET " . $_GET["offset"] . " ";
$result = mysql_query($query,$db);

// Display data if any found, message if none found

if ($db_row = mysql_fetch_array($result)) {
	do {
		echo "\t<tr>
		<td>" . $db_row["id"] . "</td>
		<td><a href=\"../character_/?account_id=" . $db_row["id"] . "\">" . $db_row["name"] . "</a></td>
		<td>";
if ($db_row["character_id"] != "") {echo "<a href=\"../inventory/?id=" . $db_row["character_id"] . "\">" . $db_row["charname"] . "</a>";}
else {echo $db_row["charname"];};
		echo "</td>
		<td align=\"right\">" . $db_row["sharedplat"] . "</td>
		<td align=\"center\" title=\"" . $db_row["password"] . "\">";
			if ($db_row["password"]) {echo "Y";}
			else {echo "N";};
		echo "</td>
		<td>" . $db_row["status"] . "</td>
		<td align=\"right\">" . $db_row["lsaccount_id"] . "</td>
		<td>" . $db_row["gmspeed"] . "</td>
		<td>" . $db_row["revoked"] . "</td>
<!--		<td>" . $db_row["minilogin_ip"] . "</td>	-->
		<td>" . $db_row["hideme"] . "</td>
		<td>" . $db_row["rulesflag"] . "</td>
	</tr>\n";
	flush(); ob_flush();
	} while ($db_row = mysql_fetch_array($result));
} else {
	echo "\t\t<td align=\"center\" colspan=\"16\">No records found</td>
	</tr>";
};

?>
</table>

<?php

include "../includes/footer.php";

?>

</body>

</html>